<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<script>
			var t = null;
			
			function time() {
				clearTimeout(t); //清除定时器
				dt = new Date();
				var h = dt.getHours(); //获取时
				var m = dt.getMinutes(); //获取分
				var s = dt.getSeconds(); //获取秒
				document.getElementById("showTime").innerHTML = "现在星期：" + dt.getDay() + " 现在的时间为：" + dt.getFullYear() + "年" + (dt
					.getMonth() + 1) + "月" + dt.getDate() + "日" + h + "时" + m + "分" + s + "秒";
				t = setTimeout(time, 1000); //设定定时器，循环执行
			}
			function startTime(){
				time();
				t = setTimeout(time, 1000); //开始执行
			}
		</script>
	</head>
	<body onload="startTime()">
		<label id="showTime"></label>
	</body>
</html>
